package com.xxyuan.batch._03_param_validator;

import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersInvalidException;
import org.springframework.batch.core.JobParametersValidator;
import org.springframework.util.StringUtils;

/**
 * name值为空或者空串，校验不通过
 */
public class NameParamValidator implements JobParametersValidator {
    @Override
    public void validate(JobParameters parameters) throws JobParametersInvalidException {
        String name = parameters.getString("name");
        if (!StringUtils.hasText(name)){
            throw new JobParametersInvalidException("name参数值不能为空");
        }
    }
}
